# =========================================================================
# File: Makefile
#
# Copyright (c) 2006 and onwards, Josh Glover <jmglov@jmglov.net>,
# Robert Ota Dieterich <otanobunaga@gmail.com>
#
# LICENCE:
#
#   This file is distributed under the terms of the BSD-2 License.
#   See the COPYING file, which should have been distributed with
#   this file, for details. If you did not receive the COPYING file,
#   see:
#
#   http://www.jmglov.net/opensource/licenses/bsd.txt
#
# DESCRIPTION:
#
#   Makefile for Tokyo Missile Command
#
# USAGE:
#
#   make <target>
#
#   Run 'make help' to see a list of all targets and what they do
#
# EXAMPLES:
#
#   make && sudo make install
#   make doc
#
# DEPENDENCIES:
#
#   awk (tested with GNU awk)
#   C++ compiler (tested with GNU g++)
#   grep (tested with GNU grep)
#   make (tested with GNU make)
#   tar (tested with GNU tar; for targets: dist)
#
# TODO:
# 
#   - Nothing, this code is perfect
#  
# MODIFICATIONS:
#
#   Josh Glover <jmglov@jmglov.net> (2006/07/30): Initial revision
# =========================================================================

## (Unix) Name of the project
NAME = TokyoMissileCommand

## Version of the project
VERSION = `cat VERSION`

## Programs used by Makefile
#--------------------------------------------------------------------------

# If these are not in your $PATH, specify the full path
AWK         = gawk
CPP         = g++
EBUILD      = ebuild
GREP        = grep
TAR         = tar

#--------------------------------------------------------------------------

## Compilation-related
#--------------------------------------------------------------------------

## Path to SDL includes
SDL_INCLUDE_PATH = /usr/include/SDL

## Flags for the C++ compiler
CPPFLAGS = -I${SDL_INCLUDE_PATH} -Wall -lSDL -lSDL_gfx

## The base directory for installation (prepended *before* $(PREFIX)
DESTDIR =

## Installation prefix (e.g. 'make "PREFIX = /usr" install would install
## files in /usr/lib, /usr/include, and /usr/man)
PREFIX  = /usr/local

## C++ source files
CPPFILES  = ${NAME}.cc Missile.cc MobileSprite.cc ObjBase.cc Sprite.cc

## C++ header files
HFILES  = Building.h City.h Missile.h MissileLauncher.h MobileSprite.h \
          ObjBase.h Sprite.h

#--------------------------------------------------------------------------


## Build Tokyo Missile Command
build : $(CPPFILES) $(HFILES)
	$(CPP) $(CPPFLAGS) -o $(NAME) $(CPPFILES)

clean : 
	- rm -rf $(NAME)

debug :
	$(MAKE) "CPPFLAGS = $(CPPFLAGS) -g" build

help :
	@ echo 'Usage: make {<target>}'
	@ echo
	@ echo '  where valid <target>s are:'
	@ echo
	@ echo '    build:     builds the shared library'
	@ echo '    clean:     removes all object files'
	@ echo '    help:      displays this message'
	@ echo '    install:   installs to $(PREFIX)'
	@ echo '    uninstall: removes from $(PREFIX)'
	@ echo '    query:     displays the versions of ${NAME}'
	@ echo

install : build
	@ base=$(DESTDIR)$(PREFIX);\
	for i in $$base/bin;\
	do\
	  if test ! -d $$i; then\
	    echo mkdir -p $$i;\
	    mkdir -p $$i;\
	  fi;\
	done
	cp $(NAME) $(DESTDIR)$(PREFIX)/bin/

uninstall :
	- rm $(PREFIX)/bin/$(NAME)
